/*
 * Copyright (c) 2002-2003 by OpenSymphony
 * All rights reserved.
 */
package com.company.workflow.loader;

import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;

import org.w3c.dom.Element;

import com.opensymphony.workflow.InvalidWorkflowDescriptorException;
import com.opensymphony.workflow.loader.ValidationHelper;
import com.opensymphony.workflow.loader.XMLUtil;
import com.opensymphony.workflow.util.Validatable;


/**
 * DOCUMENT ME!
 *
 * @author $author$
 * @version $Revision: 1.3 $
 */
public class SplitDescriptor extends AbstractDescriptor implements Validatable {
    //~ Instance fields ////////////////////////////////////////////////////////

    protected List results = new ArrayList();

    //~ Constructors ///////////////////////////////////////////////////////////

    public SplitDescriptor() {
    }


    //~ Methods ////////////////////////////////////////////////////////////////

    public List getResults() {
        return results;
    }

    public void validate() throws InvalidWorkflowDescriptorException {
        ValidationHelper.validate(results);
    }

    public String getXML() {
    	StringBuffer buf = new StringBuffer();
        buf.append("<split id=\"" + getId() + "\">");

        for (int i = 0; i < results.size(); i++) {
            ResultDescriptor result = (ResultDescriptor) results.get(i);
            buf.append(result.getXML());
        }

        buf.append("</split>");
        return buf.toString();
    }

}
